/**
 * @Description : main
 * @author : August_xiao 1932794922@qq.com
 * @date : 2022-02-27 0:03
 */

import { createApp } from 'vue'

import store from './store'
import router from './router'
import App from './App.vue'
import { getApikey } from '@/api/thirdParty/thirdparty'
import { getRecordUser } from '@/api/article/article'
// 这个nprogress样式必须引入
import 'nprogress/nprogress.css'
// 清除默认样式
import './assets/css/global.css'
import './assets/css/mainstyle.css'
import './assets/css/font-awesome.min.css'
import 'font-awesome-animation/css/font-awesome-animation.css'

import 'tocbot/src/scss/tocbot.scss'

//引入动画样式
import 'animate.css'

import 'jquery'

//轮播图
import Carousel from 'v3-carousel' // 引入

//markdown 编辑器
const app = createApp(App)

/**
 * 自定义标题
 */
app.directive('title', {
  beforeMount(el, binding) {
    document.title = binding.value
  },
  updated(el) {
    if (!el.dataset) {
      document.title = el.dataset.title
    }
  }
})

/**
 * 路由拦截器
 */
router.beforeEach((to, from, next) => {
  getApikey().then((res) => {
    if (null != res.data.IP_Address) {
      let params = {
        path: to.fullPath,
        ip: res.data.IP_Address
      }
      getRecordUser(params).then(() => {})
    }
  })
  next()
})

app.use(store).use(router).use(Carousel).mount('#app')
